package by.grsu.matrenichev.Initialiser;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import by.grsu.matrenichev.dao.StudentDao;
import by.grsu.matrenichev.dao.TutorDao;
import by.grsu.matrenichev.dao.TestingDao;
import by.grsu.matrenichev.entity.Student;
import by.grsu.matrenichev.entity.Tutor;
import by.grsu.matrenichev.entity.Testing;

import com.epam.grsulab.webapi.dao.base.Dao;
import com.epam.grsulab.webapi.entity.base.BaseEntity;
import com.epam.grsulab.webapi.tools.DataInitialiser;

@Component

public class DataInitialiserImpl implements DataInitialiser {
	private static final Logger logger = LoggerFactory.getLogger(DataInitialiserImpl.class);
 @Autowired
private StudentDao studentDao;
@Autowired
private TestingDao testingDao;
@Autowired
private TutorDao tutorDao;
@Override
public void initData() {
	 Testing tes2 = new Testing();
	tes2.setTestname("mathtest");
	tes2.setSubject("math");
	tes2.setQuestion1("2+2");
	tes2.setQuestion2("3*5");
	tes2.setQuestion3("sin(pi/2)");
	tes2.setMark(9);

   tes2=testingDao.save(tes2);
	 Tutor tut = new Tutor();
	tut.setN(1);
	tut=tutorDao.save(tut);
	
	 Student stud=new Student();
	stud.setFirstname("Yaroslav");
	stud.setLastname("Matrenichev");
	stud.setTestname("mathtesting");
	stud.setSubject("math");
	stud.setMark(9);
	stud.setTut(tut);
	stud.setTes(tes2);
	stud=studentDao.save(stud);

}
@Override
public List<Dao<? extends BaseEntity>> getAllDAOs() {
	// TODO Auto-generated method stub
	List<Dao<? extends BaseEntity>> list = new ArrayList<Dao<? extends BaseEntity>>();
list.add(testingDao);
	list.add(tutorDao);
	list.add(studentDao);
	return list;
	
}
}

